<%@ page contentType="text/html; charset=utf-8" language="java" import="SmallEmail.*" errorPage="" %>
<%@page import="manage.BugManage"%>
<%@page import="manage.UserManage"%>
<%@page import="object.User"%>
<%@page import="object.Bug"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'SendEmails.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
 <%
    int BugID=Integer.parseInt(request.getParameter("BugID"));
    //out.print(BugID);
    Bug bug=BugManage.getBug(BugID);
    String mailnames=null;
    mailnames=bug.getMailTo();
   // out.print(mailnames);
    if(mailnames!=null)
   { 
     String mailtos[]=mailnames.split(",");
     String ServerHost="mail.nenu.edu.cn";
     String ServerPort="25";
     String UserName="qianlh252@nenu.edu.cn";
     String Pwd="47973222";
     String FromAddress="qianlh252@nenu.edu.cn";
     String ToAddress=null;
     String Subject="新bug信息";
     String Content="bug编号："+"32"+" ;bug标题："+bug.getBugTitle()+" ;bug指派人员："+bug.getAssignedToName()+" ;bug所属项目编号："+bug.getProjectID()+" ;bug项目名称："+bug.getProjectName()+";bug模块编号:"+bug.getModuleID()+" ;bug模块名称："+bug.getModuleName();
   //  out.print(Content);

     
    for(int i=0;i<mailtos.length;i++)
     {if(!mailtos[i].equals("null"))
       {
         //发送邮件
	        ToAddress=UserManage.GetUserID(mailtos[i]).getEmail();
	        MailSenderInfo mailinfo=new MailSenderInfo();
			mailinfo.setMailServerHost(ServerHost);
			mailinfo.setMailServerPort(ServerPort);
			
			mailinfo.setValidate(true);
			mailinfo.setUserName(UserName);
			mailinfo.setPassword(Pwd);
			mailinfo.setFromAddress(FromAddress);
			mailinfo.setToAddress(ToAddress);
			mailinfo.setSubject(Subject);
			mailinfo.setContent(Content);
			SimpleMailSender sms=new SimpleMailSender();
			sms.sendTextMail(mailinfo);
			         
			
         
         
         
       }    
      
     }
    
  }
  
   response.sendRedirect("BugInfo.jsp?BugID="+BugID);
 %>  
 
 
 

  </body>
</html>
